/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package samoloty.view;

import Utils.MyOwnFocusTraversalPolicy;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.util.Locale;
import java.util.Vector;
import javax.swing.Box;
import javax.swing.BoxLayout;


/**
 *
 * @author borysfan
 */
public class MainPanel extends ContentPanel {
    private MyLabel title;
    private MyButton aircraftBtn1;
    private MyButton aircraftBtn2;
    private MyButton aircraftBtn3;
    private MyButton aircraftBtn4;
    private MyButton aircraftBtn5;
    private MyButton aircraftBtn6;
    private MyButton aircraftBtn7;
    private MyButton aircraftBtn8;
    private MyOwnFocusTraversalPolicy travelsalPolicy;

    public MainPanel(){
        super();
        initPanel();
    }

    private void initPanel(){
        setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

        title = new MyLabel("SELECT AIRCRAFT:");
        title.setBold();
        title.setAlignmentX(CENTER_ALIGNMENT);
        
        aircraftBtn1 = new MyButton("ATR-42",300,40);
        aircraftBtn1.requestFocus();
        aircraftBtn2 = new MyButton("ATR-72",300,40);
        aircraftBtn3 = new MyButton("ERJ 170-100",300,40);
        aircraftBtn4 = new MyButton("ERJ 170-200",300,40);
        aircraftBtn8 = new MyButton("ERJ 190-200",300,40);
        aircraftBtn5 = new MyButton("B737-500",300,40);
        aircraftBtn6 = new MyButton("B737-400",300,40);
        aircraftBtn7 = new MyButton("B767",300,40);


        this.add(title);
        add(Box.createRigidArea(new Dimension(0,40)));
        add(aircraftBtn1);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn2);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn3);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn4);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn8);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn5);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn6);
        add(Box.createRigidArea(new Dimension(0,20)));
        add(aircraftBtn7);

        serOrderList();
    }



    public void serOrderList() {
        Vector<Component> focusOrder = new Vector<Component>();
        focusOrder.add(aircraftBtn1);
        focusOrder.add(aircraftBtn2);
        focusOrder.add(aircraftBtn3);
        focusOrder.add(aircraftBtn4);
        focusOrder.add(aircraftBtn8);
        focusOrder.add(aircraftBtn5);
        focusOrder.add(aircraftBtn6);
        focusOrder.add(aircraftBtn7);
        travelsalPolicy = new MyOwnFocusTraversalPolicy(focusOrder);
        this.setFocusTraversalPolicy(travelsalPolicy);
        this.setFocusTraversalPolicyProvider(true);
        this.setFocusCycleRoot(true);
    }

    public void setAircraftBtn1Action(ActionListener listener){
        aircraftBtn1.addActionListener(listener);
    }

    public void setAircraftBtn2Action(ActionListener listener){
        aircraftBtn2.addActionListener(listener);
    }

    public void setAircraftBtn3Action(ActionListener listener){
        aircraftBtn3.addActionListener(listener);
    }

    public void setAircraftBtn4Action(ActionListener listener){
        aircraftBtn4.addActionListener(listener);
    }

    public void setAircraftBtn5Action(ActionListener listener){
        aircraftBtn5.addActionListener(listener);
    }

    public void setAircraftBtn6Action(ActionListener listener){
        aircraftBtn6.addActionListener(listener);
    }

    public void setAircraftBtn7Action(ActionListener listener){
        aircraftBtn7.addActionListener(listener);
    }

    public void setAircraftBtn8Action(ActionListener listener){
        aircraftBtn8.addActionListener(listener);
    }

    public void setFirstFocused(){
        aircraftBtn1.requestFocus();
    }
}
